//
//  NewsListTableViewModel.m
//  JiZhuiAn
//
//  Created by roger lin on 16/7/10.
//  Copyright © 2016年 Easy. All rights reserved.
//

#import "NewsListTableViewModel.h"

@implementation NewsListTableViewModel

- (RACSignal *)refreshDataSignalWithPage:(NSUInteger)page
{
    return [[[APIService shareService]loadTheWebsiteInfo] doNext:^(NSArray *array) {
        NSMutableArray *newArray = [[NSMutableArray alloc]init];
        for (int i = 0; i < [array count] ; i++) {
            NewsArticleViewModel *viewModel = [[NewsArticleViewModel alloc]init];
            [viewModel setParam:(BmobObject *)[array objectAtIndex:i]];
            [newArray addObject:viewModel];
        }
        self.dataSource = newArray;
    }];
}

- (RACSignal *)didSelectedSignalWithIndexPath:(NSIndexPath *)indexPath
{
    return [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {
        [subscriber sendNext:indexPath];
        [subscriber sendCompleted];
        return nil;
    }];
}

@end
